function main(defaultParams) {
    const self = this;
    debugger
    if (defaultParams.moduleActionType !== 'form-save') {
        return;
    }

    var documentNo = defaultParams.callbackParams.result.documentNo;

    const pageListEle = self.$$("page_widget_list_hkmx62");
    const pageListEle1 = self.$$("page_widget_list_7b12fk");
    const listRenderView = pageListEle.$$getRenderElement();
    const listRenderView1 = pageListEle1.$$getRenderElement();
    const currentListEle = listRenderView.$$getListElement();
    const currentListEle1 = listRenderView1.$$getListElement();

    submitProcess(self, defaultParams, documentNo)
        .then(function (response) {
            self.$message.success("流程发起成功");
            refreshTables(currentListEle, currentListEle1);
        })
        .catch(function (error) {
            // Error message is handled in submitProcess
            refreshTables(currentListEle, currentListEle1);
        });
}

function submitProcess(self, defaultParams, documentNo) {
    return new Promise(function (resolve, reject) {
        const queryParams = [{
            name: "pageId",
            valueContent: "4d080a08-d4d1-4490-86e4-139d7aa0a3dd"
        }];

        var jsonParams = {
            documentNo: documentNo
        };

        console.log("Submit params:", defaultParams);

        api.DATA_SOURCE_EXECUTE(
            "a2b29830-9ef5-437a-8975-476783d4e73f",
            "api",
            queryParams,
            [],
            JSON.stringify(jsonParams)
        ).then(function (res) {
            console.log("Response:", res);
            if (res && res.hasError) {
                self.$message.error(res.message);
                reject(res);
            } else {
                resolve(res);
            }
        }).catch(function (err) {
            self.$message.error(err.message);
            reject(err);
        });
    });
}

function refreshTables(table1, table2) {
    table1.$$refreshData();
    table2.$$refreshData();
}
